import { defineStore } from 'pinia'

// 按需导出
export const useCounterStore = defineStore("counter", {
    state: () => {
        return { 
            value: 1 
        }
    },
    getters: {
        // count: state => state.value
        count: state => { 
            return state.value 
        },
        double: state => {
            // 返回当前状态值的两倍
            return state.value * 2;
        }
    },
    actions: {
        increment() {
            return this.value++;
        }
    }
});